feat(components): Allow Configuration of AnimatedPresence#2898
Closed
feat(components): Allow Configuration of AnimatedPresence#2898
Conversation
Deploying atlantis with
|
| Latest commit: |
a092313
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://78e85784.atlantis.pages.dev |
| Branch Preview URL: | https://job-150838-animatedpresence.atlantis.pages.dev |
|
Published Pre-release for a9a05ad with versions: To install the new version(s) for Web run: |
ZakaryH
commented
Feb 7, 2026
| /** | ||
| * The timing of the animation. | ||
| */ | ||
| readonly timing?: Timing; |
Contributor
Author
There was a problem hiding this comment.
not 100% on this interface
you'll be passing values like "timing-slow" rather than just "slow"
buut it is derived from the tokens which is nice. the only time it might become a hindrance is if we change the token values, the props would need to get fixed in the invocations.
ZakaryH
commented
Feb 7, 2026
|
|
||
| export type AnimatedPresenceTransitions = keyof typeof transitions; | ||
|
|
||
| type ExitBehavior = "overlap" | "replace" | "sequential"; |
Contributor
Author
There was a problem hiding this comment.
let me know if these are good, clear names.
I had a couple other ideas to describe "overlap" (crossfade)
and "immediate" instead of "replace"
the actual framer motion values they map to are:
- "overlap" -> "sync"
- "replace" -> "popLayout"
- "sequential" -> "wait"
and here's their descriptions
/**
* Determines how to handle entering and exiting elements.
*
* - `"sync"`: Default. Elements animate in and out as soon as they're added/removed.
* - `"popLayout"`: Exiting elements are "popped" from the page layout, allowing sibling
* elements to immediately occupy their new layouts.
* - `"wait"`: Only renders one component at a time. Wait for the exiting component to animate out
* before animating the next component in.
*
* @public
*/
mode?: "sync" | "popLayout" | "wait";
Contributor
Author
Contributor
Author
|
see above |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivations
currently AnimatedPresence (and AnimatedSwitcher) have a static timing, and don't allow you to choose the
modethat is used for enter/exit.the "popLayout" mode can cause issues with some layouts where the animated content is the last thing in the document, causing it to visually shift heights as the exiting element is immediately removed and for a fraction of a second, the other content isn't yet there. so, by allowing choice of exit/enter behavior, this can be tailored to the situation.
as for the timing, we have timing tokens. it seems odd that we would not allow other valid, consistent timing values to be used.
the callback is there so that a consumer can deal with some possible layout quirks such as the one we encountered. it may not solve this case, but I think it's a useful prop to have regardless.
Changes
Added
timingpropexitBehaviorproponExitCompletepropI've intentionally tried to name the
exitBehaviorprop values with more "what"-style names. I do not want us to be tied to framer-motions API, and struggle to figure out what an equivalent is later down the road if we should swap the underlying library. using terms like "sequential" makes it clear to both a consumer and us what is desired VS "wait" which is the library's terminology.Changed
Deprecated
Removed
Fixed
Security
Testing
try the various timing tokens, seee that they do what you expect.
try the new callback, see that it fires when you expect
for the exitBehavior I've added a webstory to demonstrate the difference between the exitBehavior prop value. to see the exact issue, what you'll need is pretty specific:
once we have that, the scenario is that you scroll down and start initiating the animations that swap. using "replace" is the current issue, so you can try that. "sequential" from some testing had the same issue though.
the reason being that the content gets shorter for a frame or two, and we're scrolled to a place that doesn't exist so the scroll/position moves for a moment.
aside from that, just try out the different exitBehavior prop values to make sure they look and feel good! keep in mind they can be combined with all the various
transitionvalues!Changes can be
tested via Pre-release
In Atlantis we use Github's built in pull request reviews.